﻿using OfficeOpenXml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cad.Infrastructure
{
    public class ExcelUtility
    {

        public static List<T>  Get<T>(string path,string sheet= "Sheet1") where T : class ,new()
        {
            var package = new ExcelPackage(path);
            ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
            var workbook = package.Workbook;
            var worksheet = workbook.Worksheets[sheet];
            var result = worksheet.ConvertSheetToObjects<T>().ToList();

            return result;  

        }

    }
}

